package com.yqy.spring.T1.SimpleFactory;

public class WeaponFactory {
    public static Weapon getWeapon(String weaponName){
        if (weaponName==null ||weaponName.trim().length()==0){
            return null;
        }
        Weapon weapon=null;
        if (weaponName.equals("Dagger")){
            weapon=new Dagger();
        }else if(weaponName.equals("Gun")){
            weapon=new Gun();
        }else if (weaponName.equals("Tank")){
            weapon=new Tank();
        }else{
            throw new RuntimeException("武器库中没有该武器！");
        }
        return weapon;
    }
}
